﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WPFControls
{
	/// <summary>
	/// DrowdownMenu.xaml 的交互逻辑
	/// </summary>
	public partial class DrowdownMenu : UserControl
	{
        public event XMenuClickDelType XItemClick;

		public DrowdownMenu()
		{
			this.InitializeComponent();
            item1.XClick += new MouseButtonEventHandler(item1_XClick);
            item2.XClick += new MouseButtonEventHandler(item2_XClick);
            item3.XClick += new MouseButtonEventHandler(item3_XClick);
		}

        void item1_XClick(object sender, MouseButtonEventArgs e)
        {
            this.Visibility = System.Windows.Visibility.Hidden;
            if (XItemClick != null)
            {
                XItemClick.Invoke(0);
            }
        }

        void item2_XClick(object sender, MouseButtonEventArgs e)
        {
            this.Visibility = System.Windows.Visibility.Hidden;
            if (XItemClick != null)
            {
                XItemClick.Invoke(1);
            }
        }

        void item3_XClick(object sender, MouseButtonEventArgs e)
        {
            this.Visibility = System.Windows.Visibility.Hidden;
            if (XItemClick != null)
            {
                XItemClick.Invoke(2);
            }
        }
	}

    public delegate void XMenuClickDelType(int index);
}